package com.mlz.mlzmall.ui.activity.act.order;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.mlz.mlzmall.R;
import com.mlz.mlzmall.ui.activity.act.personal.MyOrder;


public class EhkingActivity extends Activity {
    WebView wv_ehking;
    boolean backtoMyOrder = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ehking);
        // 初始化
        initView();
        // 显示支付界面
        StartEhkPay();

    }

    // 初始化webView
    private void initView() {
        wv_ehking = (WebView) findViewById(R.id.wv_ehking);
    }

    private void StartEhkPay() {

        try {
            wv_ehking.getSettings().setJavaScriptEnabled(true);
            wv_ehking.loadUrl(this.getIntent().getStringExtra("redirectUrl").toString());
            wv_ehking.setWebViewClient(new WebViewClient() {
                // 单击超链接
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {

                    if (null != url && !backtoMyOrder) {
                        Intent intent = new Intent(EhkingActivity.this, MyOrder.class);
                        startActivity(intent);
                        // 支付后，跳转成功
                        backtoMyOrder =true;
                        return true;
                    }
                    return super.shouldOverrideUrlLoading(view, url);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
